package ooo.reindeer.concurrent.coder;

import ooo.reindeer.concurrent.ICoder;

import java.io.UnsupportedEncodingException;

public class StringCoder implements ICoder<String, byte[]> {
    @Override
    public String decode(byte[] bytes) {
        try {
            return new String(bytes, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public byte[] encode(String a) {
        try {
            return a.getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
}
